﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Core.Business;
using Core.Entity;
namespace TicketManagement.Template
{
    public partial class uHeader : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            if (Session["User"] != null)
            {
                UserBus userBus = new UserBus();
                Core.Entity.User user = userBus.get((int)Session["User"]);
                if (user.UserTypeId == 4)
                {
                    // User is an account
                    AccountBus accountBus = new AccountBus();
                    Core.Entity.Account account = accountBus.getAccountByUserId(user.Id);
                    lblCode.InnerText = account.Code;
                    lblName.InnerText = account.OwnerName;
                    lnkProfile.HRef = "/Account/Profile.aspx";
                }
                else
                {
                    // User is a staff
                    StaffBus staffBus = new StaffBus();
                    Core.Entity.Staff staff = staffBus.getStaffByUserId(user.Id);
                    lblCode.InnerText = staff.Code;
                    lblName.InnerText = staff.FullName;
                    lnkProfile.HRef = "/Staff/Profile.aspx";
                }
            }
        }
    }
}